package com.csun.dsms.utils;

import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.google.gson.Gson;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class SmsUtils {


    public void sendMsg(String phone,String jsonStr){
        if (phone.equals("18186261208") ||
                phone.equals("13207258666") ||
                phone.equals("13871497165")){
            return;
        }
        String KEY_ID = "LTAI5tDxh8NdYBM7UT1NR3hF";
        String KEY_SECRET = "G8k1wpGYfkCeyVRrK3yleUzBCMqfRa";
        String signName = "扬尘治理监测小程序";
        String sendPhone = phone;
        String TemplateCode = "SMS_461330733"; // 模板code
        String TemplateParam = jsonStr;  //json
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 必填，您的 AccessKey ID
                .setAccessKeyId(KEY_ID)
                // 必填，您的 AccessKey Secret
                .setAccessKeySecret(KEY_SECRET);
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        try {
            com.aliyun.dysmsapi20170525.Client client = new
                    com.aliyun.dysmsapi20170525.Client(config);
            com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest =
                    new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
                    .setPhoneNumbers(sendPhone)
                    .setSignName(signName)
                            .setTemplateCode(TemplateCode)
                            .setTemplateParam(TemplateParam);
            client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }




}
